package org.suze.redis.client;

import org.suze.redis.connection.Connection;
import org.suze.redis.protocol.Protocol;

/**
 * @description: Redis 客户端类
 * @Date : 2018/9/21 下午8:43
 * @Author : 石冬冬-Seig Heil(dongdong.shi@mljr.com)
 */
public class Client {

    protected Connection connection;

    public Client(String host,int port) {
        this.connection = new Connection(host,port);
    }

    public String set(String key, String value){
        connection.sendCommand(Protocol.Command.SET,key.getBytes(),value.getBytes());
        return connection.getStatusCodeReply();
    }
    public String get(String key){
        connection.sendCommand(Protocol.Command.GET,key.getBytes());
        return connection.getStatusCodeReply();
    }

    public static void main(String[] args) {
        Client client = new Client("localhost",6379);
        client.get("1000");
    }
}
